﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace TruyenAudio
{
    public partial class TapTruyen : PhoneApplicationPage
    {
        public TapTruyen()
        {
            InitializeComponent();
            txtTenTruyen.Text = ListItem.TenTruyen;

        }

        private void listTapTruyen_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Item item = (Item)listTapTruyen.SelectedItem;
            txtTen.Text = item.ProductName.ToString();
            ListItem.Taptruyen = item.ProductName.ToString();
            ListItem.LinkTruyen = item.Link.ToString();
        }

        private void btnPlay_Click(object sender, RoutedEventArgs e)
        {
            if (txtTen.Text.Trim().Equals(""))
            {
                MessageBox.Show("Chọn tập truyện cần nghe !", "Thông Báo", MessageBoxButton.OK);
            }
            else
            {
                ((App)Application.Current).RootFrame.Navigate(new Uri("/MediaPlay.xaml", UriKind.Relative));
            }
        }
        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            //MessageBoxResult kq = MessageBox.Show("Bạn muốn quay lại ?", "Thông Báo", MessageBoxButton.OKCancel);
            //if (kq == MessageBoxResult.OK)
            //{
            ((App)Application.Current).RootFrame.Navigate(new Uri("/DanhSachTruyen.xaml", UriKind.Relative));
            //}
            //else
            //{
            //    e.Cancel = true;
            //}
        }

    }
}